# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=mots
pkgver=5.34017ca
pkgrel=6
groups=('blackarch' 'blackarch-sniffer' 'blackarch-networking' 'blackarch-spoof'
        'blackarch-defensive')
pkgdesc='Man on the Side Attack - experimental packet injection and detection.'
arch=('any')
url='https://github.com/kevinkoo001/MotS'
license=('custom:unknown')
depends=('python2' 'python2-netifaces' 'python2-scapy')
makedepends=('git')
source=("$pkgname::git+https://github.com/kevinkoo001/MotS.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  _tools='quantumdetect quantuminject'

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  for i in $_tools
  do
    cat > "$pkgdir/usr/bin/$i" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $i.py "\$@"
EOF
    chmod +x "$pkgdir/usr/bin/$i"
  done
}

